<?php
/*
	Plugin Name: Foxnet Kino
	Plugin URI: http://foxnet.fi
	Description: Register movie site in WordPress theme
	Author: Sami Keijonen
	Version: 0.1
	Author URI: http://foxnet.fi
*/

/* Set up the plugin. */
add_action( 'plugins_loaded', 'foxnet_kino_setup' );

/**
 * Sets up the Foxnet Kino plugin and loads files at the appropriate time.
 *
 * @since 0.1
 */
function foxnet_kino_setup() {

	/* Set constant path to the Foxnet Kino plugin directory. */
	define( 'FOXNET_KINO_DIR', plugin_dir_path( __FILE__ ) );

	/* Set constant path to the Foxnet Kino plugin url. */
	define( 'FOXNET_KINO_URL', plugin_dir_url( __FILE__ ) );

	/* Load the translation of the plugin. */
	load_plugin_textdomain( 'foxnet-kino', false, 'foxnet-kino/languages' );

	/* Add Custon Post Types movies. */
	add_action( 'init', 'foxnet_kino_register_my_post_type_movies' );
	
	/* Add taxonomies Genre, Director, Actors, Age limit for movies Post Type. Those are not hierarchical.
	*  Also add hierarchical taxonomy like 'categories' Now playing, Upcoming movies
	****************************************************************************************************/
	add_action( 'init', 'foxnet_kino_register_my_taxonomy' );
	
	/* Add custom meta box for movies */
	add_action( 'add_meta_boxes', 'foxnet_kino_create_meta_boxes' );
	
	/* Save metabox data */
	add_action( 'save_post', 'foxnet_kino_save_meta_boxes' );
	
	/* Add new image size */
	add_action( 'init', 'foxnet_kino_register_image_sizes' );
	
	/* Filter movies order alphabetically with pre_get_posts-function */
	add_filter('pre_get_posts', 'foxnet_kino_custom_post_types_admin_order'); 
	
	/* Add functions/tabs in Hybrid Tab plugin */
	add_action( 'init', 'foxnet_kino_create_my_custom_tabs' );
	
	/* Add shortcodes [movie-information] and [movie-showtimes], can be used in post or pages */
	add_shortcode( 'movie-information', 'foxnet_kino_movie_info_shortcode' );
	add_shortcode( 'movie-showtimes', 'foxnet_kino_movie_showtimes_shortcode' );
	
	/* add filter to ensure the text Movie, or movie, is displayed when user updates a movie
	** @link http://codex.wordpress.org/Function_Reference/register_post_type
	*/ 
	add_filter( 'post_updated_messages', 'foxnet_kino_movie_updated_messages' );

}
 
/* Add Custon Post Types movies. */
function foxnet_kino_register_my_post_type_movies() {
	
	/* Set arguments for the movies Custom Post Type. */
	/* @link http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress */
	$movies_args = array(
		'public' => true, 
		'query_var' => 'movies',
		'menu_position' => 5,
		'menu_icon' => FOXNET_KINO_URL . '/images/video.png',
		'supports' => array(
			'title',
			'editor',
			'thumbnail',
			'excerpt',
			'comments',
			'trackbacks',
			'revisions',
			'custom-fields'
		),
		'labels' => array(
			'name' => __( 'Movies', 'foxnet-kino' ),
			'singular_name' => __( 'Movie', 'foxnet-kino' ),
			'add_new' => __( 'Add New', 'foxnet-kino' ),
			'add_new_item' => __( 'Add New Movie', 'foxnet-kino' ),
			'edit' => __( 'Edit', 'foxnet-kino' ),
			'edit_item' => __( 'Edit Movie', 'foxnet-kino' ),
			'new_item' => __( 'New Movie', 'foxnet-kino' ),
			'view' => __( 'View Movie', 'foxnet-kino' ),
			'view_item' => __( 'View Movie', 'foxnet-kino' ),
			'search_items' => __( 'Search Movies', 'foxnet-kino' ),
			'not_found' => __( 'No movies found', 'foxnet-kino' ),
			'not_found_in_trash' => __( 'No movies found in Trash', 'foxnet-kino' ) 
		),
		'has_archive' => true,
		/* Global control over capabilities. @link http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types */
		//'capability_type' => 'foxnet_kino',

		/* Specific control over capabilities. 
		'capabilities' => array(
			'publish_posts' => 'publish_foxnet_kinos',
			'edit_posts' => 'edit_foxnet_kinos',
			'edit_others_posts' => 'edit_others_foxnet_kinos',
			'delete_posts' => 'delete_foxnet_kinos',
			'delete_others_posts' => 'delete_others_foxnet_kinos',
			'read_private_posts' => 'read_private_foxnet_kinos',
			'edit_post' => 'edit_foxnet_kino', // Do not give to any role.
			'delete_post' => 'delete_foxnet_kino', // Do not give to any role.
			'read_post' => 'read_foxnet_kino', // Do not give to any role.
		),*/
	);
	
	/* Register the showcase post type with showcase arguments. */
	 register_post_type( 'movies', $movies_args );	
}

/* Register taxonomies for movies Post Type. */
function foxnet_kino_register_my_taxonomy() {
	
	/* This is for movietimes like Playing now or Upcoming movies. */
	$movietimes_args = array(
		'hierarchical' => true, // like now or upcoming movies
		'query_var' => 'movietimes', 
		'show_tagcloud' => true,
		'labels' => array(
			'name' => __( 'Movietimes', 'foxnet-kino' ),
			'singular_name' => __( 'Movietime', 'foxnet-kino' ),
			'search_items' => __( 'Search Movietimes', 'foxnet-kino' ),
			'all_items' => __( 'All Movietimes', 'foxnet-kino' ),
			'edit_item' => __( 'Edit Movietime', 'foxnet-kino' ),
			'update_item' => __( 'Update Movietime', 'foxnet-kino' ),
			'add_new_item' => __( 'Add New Movietime', 'foxnet-kino' ),
			'new_item_name' => __( 'New Movietime Name', 'foxnet-kino' ),
	)	
);

/* This is for Genre */
	$genre_args = array(
		'hierarchical' => false,
		'query_var' => 'genre',
		'show_tagcloud' => true,
		'labels' => array(
			'name' => __( 'Genre', 'foxnet-kino' ),
			'singular_name' => __( 'Genre', 'foxnet-kino' ),
			'search_items' => __( 'Search Genres', 'foxnet-kino' ),
			'popular_items' => __( 'Popular Genres', 'foxnet-kino' ),
			'all_items' => __( 'All Genres', 'foxnet-kino' ),
			'edit_item' => __( 'Edit Genre', 'foxnet-kino' ),
			'update_item' => __( 'Update Genre', 'foxnet-kino' ),
			'add_new_item' => __( 'Add New Genre', 'foxnet-kino' ),
			'new_item_name' => __( 'New Genre Name', 'foxnet-kino' ),
			'separate_items_with_commas' => __( 'Sepatate Genres with commas', 'foxnet-kino' ),
			'add_or_remove_items' => __( 'Add or remove Genres', 'foxnet-kino' ),
			'choose_from_most_used' => __( 'Choose from the most popular Genres', 'foxnet-kino' ),
	)	
);	

/* This is for Director */
	$director_args = array(
		'hierarchical' => false,
		'query_var' => 'director',
		'show_tagcloud' => true,
		'labels' => array(
			'name' => __( 'Director', 'foxnet-kino' ),
			'singular_name' => __( 'Director', 'foxnet-kino' ),
			'search_items' => __( 'Search Directors', 'foxnet-kino' ),
			'popular_items' => __( 'Popular Directors', 'foxnet-kino' ),
			'all_items' => __( 'All Directors', 'foxnet-kino' ),
			'edit_item' => __( 'Edit Director', 'foxnet-kino' ),
			'update_item' => __( 'Update Director', 'foxnet-kino' ),
			'add_new_item' => __( 'Add New Director', 'foxnet-kino' ),
			'new_item_name' => __( 'New Director Name', 'foxnet-kino' ),
			'separate_items_with_commas' => __( 'Sepatate Directors with commas', 'foxnet-kino' ),
			'add_or_remove_items' => __( 'Add or remove Directors', 'foxnet-kino' ),
			'choose_from_most_used' => __( 'Choose from the most popular Directors', 'foxnet-kino' ),
	)	
);	

/* This is for Actors */
	$actors_args = array(
		'hierarchical' => false,
		'query_var' => 'actor',
		'show_tagcloud' => true,
		'labels' => array(
			'name' => __( 'Actor', 'foxnet-kino' ),
			'singular_name' => __( 'Actor', 'foxnet-kino' ),
			'search_items' => __( 'Search Actors', 'foxnet-kino' ),
			'popular_items' => __( 'Popular Actors', 'foxnet-kino' ),
			'all_items' => __( 'All Actors', 'foxnet-kino' ),
			'edit_item' => __( 'Edit Actor', 'foxnet-kino' ),
			'update_item' => __( 'Update Actor', 'foxnet-kino' ),
			'add_new_item' => __( 'Add New Actor', 'foxnet-kino' ),
			'new_item_name' => __( 'New Actor Name', 'foxnet-kino' ),
			'separate_items_with_commas' => __( 'Sepatate Actors with commas', 'foxnet-kino' ),
			'add_or_remove_items' => __( 'Add or remove Actors', 'foxnet-kino' ),
			'choose_from_most_used' => __( 'Choose from the most popular Actors', 'foxnet-kino' ),
	)	
);	

/* This is for Age limit */
	$age_limit_args = array(
		'hierarchical' => false,
		'query_var' => 'agelimit',
		'show_tagcloud' => true,
		'labels' => array(
			'name' => __( 'Age limit', 'foxnet-kino' ),
			'singular_name' => __( 'Age limit', 'foxnet-kino' ),
			'search_items' => __( 'Search Age limits', 'foxnet-kino' ),
			'popular_items' => __( 'Popular Age limits', 'foxnet-kino' ),
			'all_items' => __( 'All Age limits', 'foxnet-kino' ),
			'edit_item' => __( 'Edit Age limit', 'foxnet-kino' ),
			'update_item' => __( 'Update Age limit', 'foxnet-kino' ),
			'add_new_item' => __( 'Add New Age limit', 'foxnet-kino' ),
			'new_item_name' => __( 'New Age limit Name', 'foxnet-kino' ),
			'separate_items_with_commas' => __( 'Sepatate Age limits with commas', 'foxnet-kino' ),
			'add_or_remove_items' => __( 'Add or remove Age limits', 'foxnet-kino' ),
			'choose_from_most_used' => __( 'Choose from the most popular Age limits', 'foxnet-kino' ),
	)	
);		
			
/* Register taxonomies */
	register_taxonomy( 'movietimes', array( 'movies' ), $movietimes_args );	
	register_taxonomy( 'genre', array( 'movies' ), $genre_args );
	register_taxonomy( 'director', array( 'movies' ), $director_args );	
	register_taxonomy( 'actors', array( 'movies' ), $actors_args );
	register_taxonomy( 'agelimit', array( 'movies' ), $age_limit_args );
}

/* Adds metabox in movies post type. Showtimes, trailer, movie website, length and ticket price */
function foxnet_kino_create_meta_boxes() {
	
	add_meta_box( 'foxnet-movie-info', __( 'Movie Information', 'foxnet-kino' ), 'foxnet_kino_display_meta_boxes', 'movies', 'normal', 'high' );

}

/* Display metabox. Note that $post object is passed as a parameter, so that we can get post ID */
function foxnet_kino_display_meta_boxes( $post ) {
	
	/* get metadata values if they exist. */
	
	$foxnet_kino_showtimes = get_post_meta( $post->ID, 'foxnet_kino_showtimes', 'true' ); // Get showtimes
	$foxnet_kino_trailer = get_post_meta( $post->ID, 'foxnet_kino_trailer', 'true' ); // Get trailer
	$foxnet_kino_website = get_post_meta( $post->ID, 'foxnet_kino_website', 'true' ); // Get website
	$foxnet_kino_length = get_post_meta( $post->ID, 'foxnet_kino_length', 'true' ); // Get length
	$foxnet_kino_price = get_post_meta( $post->ID, 'foxnet_kino_price', 'true' ); // Get ticket price
	
	/* Display metadata in table. */
	 
	/* Adds WP nonce field: http://codex.wordpress.org/Function_Reference/wp_nonce_field */
	wp_nonce_field( 'foxnet-kino-nonce', 'foxnet-kino-nonce-name' );
	
	/* wp_editor settings */
	$foxnet_kino_editor_settings = array(
	'wpautop' => true,
	'media_buttons' => false,
	'textarea_rows' => 8,
	'tinymce' => array(
		'theme_advanced_buttons1' => 'bold, bullist, numlist , ordered_list, separator, undo, redo',
		'theme_advanced_buttons2' => '',
		'theme_advanced_buttons3' => '',
		'theme_advanced_buttons4' => ''
	),
	'quicktags' => array(
		'buttons' => 'b,ul,ol,li,close'
	)
);
	
	?>
	<table class="form-table">
    	<tr>
    <th class="foxnet-kino-label"><label for="foxnet-kino-movietimes"><?php  _e( 'Movie showtimes.', 'foxnet-kino' ) ?></label></th>
    <td class="foxnet-kino-field"><?php wp_editor( $foxnet_kino_showtimes, 'foxnet_kino_showtimes', $foxnet_kino_editor_settings ); ?>
    <br /> <?php _e('Only ul, ol, li, p and strong html tags are accepted.', 'foxnet-kino' ); ?>
    </td>
    </tr>
		<tr>
    <th class="foxnet-kino-label"><label for="foxnet-kino-trailer"><?php  _e( 'Movie Trailer website.', 'foxnet-kino' ) ?></label></th>
    <td class="foxnet-kino-field"><input class="widefat" type="text" size="100" name="foxnet_kino_trailer" value="<?php echo esc_attr( $foxnet_kino_trailer ) ?>" />
    <br /> <?php _e('Remember to include http://', 'foxnet-kino' ); ?>
    </td>
    </tr>
    	<tr>
    <th class="foxnet-kino-label"><label for="foxnet-kino-website"><?php  _e( 'Movie website.', 'foxnet-kino' ) ?></label></th>
    <td class="foxnet-kino-field"><input class="widefat" type="text" size="100" name="foxnet_kino_website" value="<?php echo esc_attr( $foxnet_kino_website ) ?>" />
    <br /> <?php _e('Remember to include http://', 'foxnet-kino' ); ?>
    </td>
    </tr>
    	<tr>
    <th class="foxnet-kino-label"><label for="foxnet-kino-length"><?php  _e( 'Movie duration.', 'foxnet-kino' ) ?></label></th>
    <td class="foxnet-kino-field"><input class="widefat" type="text" size="100" name="foxnet_kino_length" value="<?php echo esc_attr( $foxnet_kino_length ) ?>" />
    <br /> <?php _e('For example 2h 20min.', 'foxnet-kino' ); ?>
    </td>
    </tr>
    	<tr>
    <th class="foxnet-kino-label"><label for="foxnet-kino-price"><?php  _e( 'Movie ticket price.', 'foxnet-kino' ) ?></label></th>
    <td class="foxnet-kino-field"><input class="widefat" type="text" size="100" name="foxnet_kino_price" value="<?php echo esc_attr( $foxnet_kino_price ) ?>" />
    <br /> <?php _e('For example 12 &euro;, students 10 &euro;', 'foxnet-kino' ); ?>
    </td>
    </tr>
	</table>
    <?php
}

/* Save metabox data. Note that pass $post_id variable as a parameter. The post ID is used when saving metadata. */
function foxnet_kino_save_meta_boxes( $post_id ) {
	
	/* Verify nonce. */
	if ( !wp_verify_nonce( $_POST['foxnet-kino-nonce-name'], 'foxnet-kino-nonce' ) )
		return $post_id;
	
	/* Checks if current user can edit this movie. */
	if ( !current_user_can( 'edit_post', $post_id ) )
		return $post_id; 
		
	/* Get meta keys in an array. */
	$movie_meta_info_all = array( 'foxnet_kino_showtimes', 'foxnet_kino_trailer', 'foxnet_kino_website', 'foxnet_kino_length', 'foxnet_kino_price' );

	/* Loop through all of post meta box arguments. */
	foreach ( $movie_meta_info_all as $movie_meta_info ) {

		/* Get the meta value of the custom field key. */
		$meta_value = get_post_meta( $post_id, $movie_meta_info, true );
		
		/* Get the meta value the user input and sanitaze info. */
		
		if ( $movie_meta_info == 'foxnet_kino_showtimes' )
			$new_meta_value = foxnet_kino_check_showtimes( $_POST[ $movie_meta_info ] );
		
		if ( $movie_meta_info == 'foxnet_kino_website' || $movie_meta_info == 'foxnet_kino_trailer' )
			$new_meta_value = esc_url_raw( $_POST[ $movie_meta_info ] );
			
		if ( $movie_meta_info == 'foxnet_kino_length' || $movie_meta_info == 'foxnet_kino_price' )
			$new_meta_value = sanitize_text_field( $_POST[ $movie_meta_info ] );

		/* If a new meta value was added and there was no previous value, add it. */
		if ( $new_meta_value && '' == $meta_value )
			add_post_meta( $post_id, $movie_meta_info, $new_meta_value, true );

		/* If the new meta value does not match the old value, update it. */
		elseif ( $new_meta_value && $new_meta_value != $meta_value )
			update_post_meta( $post_id, $movie_meta_info, $new_meta_value );

		/* If there is no new meta value but an old value exists, delete it. */
		elseif ( '' == $new_meta_value && $meta_value )
			delete_post_meta( $post_id, $movie_meta_info, $meta_value );
	}		
}
/* Check showtimes. Only accepts certain html tags */
function foxnet_kino_check_showtimes( $showtimes_allowed ) {
	
	/* Allowed tags and attributes */
	$allowed_s = array (
	'ul' => array(),
	'ol' => array(),
	'li' => array(),
	'p' => array(),
	'strong' => array()
	);
	
	$showtimes_allowed = wp_kses( $showtimes_allowed, $allowed_s );
	
	return $showtimes_allowed;
}
	

/* Add new image size for movies, it's called movie-thumbnail and size is 134*186.
 * @link http://devpress.com/blog/image-sizes-in-wordpress/
*/
function foxnet_kino_register_image_sizes() {
	
	add_image_size( 'movie-thumbnail', 134, 186, true );

}

/* Order Movies */
function foxnet_kino_custom_post_types_admin_order( $query ) {  
   
    // Get the post type from the query  
    $post_type = $query->query['post_type']; 
	
	/* Order if is custom post type movie or is taxonomy movietimes, genre, director, actors or agelimit. */
	if ( 'movies' == $post_type or is_tax( 'movietimes' ) or is_tax( 'genre' ) or is_tax( 'director' ) or is_tax( 'actors' ) or is_tax( 'agelimit' ) ) {
		$query->set( 'orderby', 'title' );
		$query->set( 'order', 'asc' );
	}

	return $query; 
}  

/* Add functions in Hybrid Tab plugin: content(), showtimes, gallery. */
function foxnet_kino_create_my_custom_tabs() {
	
	if ( function_exists( 'register_hybrid_tab' ) )
		register_hybrid_tab( 'movie_synopsis', array( 'label' => __( 'Movie Synopsis', 'foxnet-kino' ), 'callback' => 'foxnet_kino_tab_movie_synopsis' ) );
	
	if ( function_exists( 'register_hybrid_tab' ) )
		register_hybrid_tab( 'movie_showtimes', array( 'label' => __( 'Movie Showtimes', 'foxnet-kino' ), 'callback' => 'foxnet_kino_tab_movie_showtimes' ) );
		
	if ( function_exists( 'register_hybrid_tab' ) )
		register_hybrid_tab( 'movie_gallery', array( 'label' => __( 'Movie Gallery', 'foxnet-kino' ), 'callback' => 'foxnet_kino_tab_movie_gallery' ) );
		
}

// Movie content tab
function foxnet_kino_tab_movie_synopsis() {
	the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'foxnet-kino' ) ); 
}

// Movie showtimes tab
function foxnet_kino_tab_movie_showtimes() {
	
	global $post; // $post->ID won't work without this
	$foxnet_kino_showtimes = get_post_meta( $post->ID, 'foxnet_kino_showtimes', 'true' );
	?>
		<div class="foxnet-kino-showtimes"><?php echo $foxnet_kino_showtimes; ?></div>
	<?php
}

// Movie picture gallery tab
function foxnet_kino_tab_movie_gallery() {
	
	/* Gallery shortcode, using Justin's Gleaner Gallery Plugin. */
    echo do_shortcode( '[gallery columns="4"]' );
}

/* Shortcode function [movie-information]. */
function foxnet_kino_movie_info_shortcode() {
	
	/* Get movies meta. */
	$foxnet_kino_trailer = get_post_meta( get_the_ID(), 'foxnet_kino_trailer', 'true' ); // Get trailer
	$foxnet_kino_website = get_post_meta( get_the_ID(), 'foxnet_kino_website', 'true' ); // Get website
	$foxnet_kino_length = get_post_meta( get_the_ID(), 'foxnet_kino_length', 'true' ); // Get length
	$foxnet_kino_price = get_post_meta( get_the_ID(), 'foxnet_kino_price', 'true' ); // Get ticket price
						
	/* Taxonomies Genre, Director, Actors, Age limit. */
	$movie_info .= '<div class="movie-information">';
	
	$movie_info .= '<p>' . get_the_term_list( get_the_ID(), 'genre', __('Genre:&nbsp;', 'foxnet-kino' ) , ', ', '') . '</p>'; 
	$movie_info .= '<p>' . get_the_term_list( get_the_ID(), 'director', __('Director:&nbsp;', 'foxnet-kino' ) , ', ', '') . '</p>'; 
	$movie_info .= '<p>' . get_the_term_list( get_the_ID(), 'actors', __('Actors:&nbsp;', 'foxnet-kino' ) , ', ', '') . '</p>'; 
	
	/* Open <p> for age, length, trailer and movie website .*/
	$movie_info .= '<p>' ;
	
	$movie_info .= get_the_term_list( get_the_ID(), 'agelimit', __('Age limit:&nbsp;', 'foxnet-kino' ) , ', ', ''); 
	
	/* Do not print empty strings. */
	if( !empty(  $foxnet_kino_length ) ) {
		$movie_info .= ', ' . __( 'Movie duration:', 'foxnet-kino' ) . ' ' ;
		$movie_info .= $foxnet_kino_length;
	}
	
	if( !empty( $foxnet_kino_trailer ) ) {
		$movie_info .= ', <a href="' . $foxnet_kino_trailer . '" title="Trailer">' ;
		$movie_info .= __( 'Trailer', 'foxnet-kino' );
		$movie_info .= '</a>' ;
	}
	
	if( !empty(  $foxnet_kino_website ) ) { /* Do not print empty strings */
		$movie_info .= ', <a href="' . $foxnet_kino_website . '" title="Website">' ;
		$movie_info .= __( 'Website', 'foxnet-kino' );
		$movie_info.= '</a>';
	}
	
	/* Close <p> for age, length, trailer and movie website. */
	$movie_info .= '</p>' ; 
	
	/* Do not print empty strings. */
	if(!empty(  $foxnet_kino_price ) ) {
		$movie_info .= '<p>' . __( 'Tickets:', 'foxnet-kino' ) . ' ' ;
		$movie_info .= $foxnet_kino_price . '</p>' ;
	}
	
	/* Close movie-information div.  */
	$movie_info.= '</div>' ;
	
	/* Return movie info. */
	return $movie_info;
}

/* Shortcode function [movie-showtimes] */
function foxnet_kino_movie_showtimes_shortcode() {
	
	/* Get movie showtimes */
	$foxnet_kino_showtimes = get_post_meta( get_the_ID(), 'foxnet_kino_showtimes', 'true' );
	
	if( !empty( $foxnet_kino_showtimes ) ) {
		$movie_showtimes .='<h3>' . __('Movie Showtimes', 'foxnet-kino' ) . '</h3>';
		$movie_showtimes .= '<div class="foxnet-kino-showtimes">'  . $foxnet_kino_showtimes . ' </div>';
	}
	
	/* Return Showtimes */
	return $movie_showtimes;
}

/* add filter to ensure the text Movie, or movie, is displayed when user updates a movie */
function foxnet_kino_movie_updated_messages( $messages ) {
  global $post, $post_ID;

  $messages['movies'] = array(
    0 => '', // Unused. Messages start at index 1.
    1 => sprintf( __('Movie updated. <a href="%s">View movie</a>', 'foxnet-kino' ) ,esc_url( get_permalink( $post_ID ) ) ),
    2 => __('Custom field updated.', 'foxnet-kino' ),
    3 => __('Custom field deleted.', 'foxnet-kino' ),
    4 => __('Movie updated.', 'foxnet-kino' ),
    /* translators: %s: date and time of the revision */
    5 => isset($_GET['revision']) ? sprintf( __('Movie restored to revision from %s', 'foxnet-kino' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    6 => sprintf( __('Movie published. <a href="%s">View movie</a>', 'foxnet-kino' ), esc_url( get_permalink( $post_ID ) ) ),
    7 => __('Movie saved.'),
    8 => sprintf( __('Movie submitted. <a target="_blank" href="%s">Preview movie</a>', 'foxnet-kino' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
    9 => sprintf( __('Movie scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview movie</a>', 'foxnet-kino' ),
      // translators: Publish box date format, see http://php.net/date
      date_i18n( __( 'M j, Y @ G:i', 'foxnet-kino' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
    10 => sprintf( __('Movie draft updated. <a target="_blank" href="%s">Preview movie</a>', 'foxnet-kino' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
  );

  return $messages;
}

?>